//
//  MovieCollectionViewCell.m
//  UI_TabBarTest1(豆瓣)
//
//  Created by dllo on 16/6/25.
//  Copyright © 2016年 司昌宝. All rights reserved.
//

#import "MovieCollectionViewCell.h"
#define kWidth self.frame.size.width
#define kHeight self.frame.size.height
#import "Movie.h"
@interface MovieCollectionViewCell ()

@property (nonatomic,retain) UIImageView *movieImageView;
@property (nonatomic,retain) UILabel *movieNameLabel;

@end


@implementation MovieCollectionViewCell

-(void)dealloc{
    [_movie release];
    [_movieImageView release];
    [_movieNameLabel release];
    [super dealloc];
}

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if(self){
        self.movieImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.movieImageView];
        [_movieImageView release];
        
        self.movieNameLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.movieNameLabel];
        [_movieNameLabel release];
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    
    self.movieImageView.frame = CGRectMake(0, 0, kWidth, kHeight * 0.8);
    NSURL *url = [NSURL URLWithString:self.movie.pic_url];
    NSData *data = [NSData dataWithContentsOfURL:url];
    UIImage *image = [UIImage imageWithData:data];
    self.movieImageView.image = image;
    
    self.movieNameLabel.frame = CGRectMake(0, kHeight * 0.8, kWidth, kHeight * 0.2);
    self.movieNameLabel.text = self.movie.movieName;
    self.movieNameLabel.textAlignment = NSTextAlignmentCenter;
    
}




@end
